﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Text;

namespace IBS.Dal.IntegrationTests
{
    public class TestHelper
    {

        private static void ExecuteSqlScript(string fileName)
        {
            var sqlConnectionString = ConfigurationManager.ConnectionStrings["IbsTest"].ConnectionString;
            using (var sqlConnection = new SqlConnection(sqlConnectionString))
            {
                sqlConnection.Open();
                var file = new FileInfo(fileName);

                string script = file.OpenText().ReadToEnd();
                var command = new SqlCommand(script, sqlConnection);
                command.ExecuteNonQuery();
            }
        }

        public static void ClearAllTables()
        {
            ExecuteSqlScript("scripts/EmptyAllTables.sql");
        }

        public static void FillStreets()
        {
            ExecuteSqlScript("scripts/FillStreets.sql");
        }

        public static void FillCurrencies()
        {
            ExecuteSqlScript("scripts/FillCurrencies.sql");
        }
    }
}
